package com.sfx.shortLink.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sfx.shortLink.common.convention.result.Result;
import com.sfx.shortLink.common.convention.result.Results;
import com.sfx.shortLink.dto.req.PageRecycleBinReqDTO;
import com.sfx.shortLink.dto.req.RecoverRecycleBinReqDTO;
import com.sfx.shortLink.dto.req.RemoveRecycleBinReqDTO;
import com.sfx.shortLink.dto.req.SaveRecycleBinReqDTO;
import com.sfx.shortLink.dto.resp.PageRecycleBinRespDTO;
import com.sfx.shortLink.service.IRecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class RecycleBinController {

    private final IRecycleBinService recycleBinService;

    @PostMapping("/api/short-link/v1/recycle-bin/save")
    public Result<Void> saveRecycleBin(@RequestBody SaveRecycleBinReqDTO requestParam) {
        recycleBinService.saveRecycleBin(requestParam);
        return Results.success();
    }

    @GetMapping("/api/short-link/v1/recycle-bin/page")
    public Result<IPage<PageRecycleBinRespDTO>> pageRecycleBin(PageRecycleBinReqDTO requestParam) {
        return Results.success(recycleBinService.pageRecycleBin(requestParam));
    }


    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecoverRecycleBinReqDTO requestParam) {
        recycleBinService.recoverRecycleBin(requestParam);
        return Results.success();
    }


    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    public Result<Void> removeRecycleBin(@RequestBody RemoveRecycleBinReqDTO requestParam) {
        recycleBinService.removeRecycleBin(requestParam);
        return Results.success();
    }
}